<?php

namespace app\admin\controller\health\website;

use app\common\controller\Backend;
use app\health\model\HealthWebsiteVideo;

class Video extends Backend
{
    public function index()
    {
        if ($this->request->isAjax()) {
            $nobuildfields = [];
            [$where, $sort, $order, $offset, $limit] = $this->custombuildparams(null, $nobuildfields);
            $params = $this->request->param();
            $where  = [];
            if (!empty($params['name'])) {
                $where['name'] = ['like', "%{$params['name']}%"];
            }
            $paginate      = HealthWebsiteVideo::where($where)
                ->order('id', 'desc')
                ->paginate($limit);
            $data['rows']  = $paginate->items();
            $data['total'] = $paginate->total();
            $this->success('', null, $data);
        }
        $this->assign('title', '视频列表');
        return $this->view->fetch();
    }

    public function preview()
    {
        $row = HealthWebsiteVideo::get($this->request->param('id', 0));
        $this->assignconfig('video', $row);
        return $this->view->fetch();
    }
}